﻿using LardonPokerSimulator.Controller;
using LardonPokerSimulator.Model;
using LardonPokerSimulator.Model.Deck;
using LardonPokerSimulator.Model.Observers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LardonPokerSimulator.View
{
    public partial class LardonForm : Form, IObserver
    {
        private ControllerLPS _controllerLPS = null;

        public LardonForm(ControllerLPS aControllerLPS)
        {
            this._controllerLPS = aControllerLPS;

            InitializeComponent();

            
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
        }

        private void LardonForm_Load(object sender, EventArgs e)
        {
           // Player[] players = Table.TableInstance.Players;

     
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Table.TableInstance.Draw(e.Graphics);


            /*SolidBrush b = new SolidBrush(Color.Green);
            SolidBrush bPlayer = new SolidBrush(Color.Red);
            SolidBrush bBlack = new SolidBrush(Color.Black);

            Rectangle r = new Rectangle(100, 100, 600, 300);
            Pen pen = new Pen(Color.SaddleBrown, 5);
            pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;

            e.Graphics.FillRectangle(b,r);
            e.Graphics.DrawRectangle(pen, r);

            int playerIndex = 0;
            int initX = 25;
            int initY = 275;

            foreach (Player p in Table.TableInstance.Players)
            {
                Rectangle rectPlayer = new Rectangle(initX, initY, 50, 50);
                playerIndex++;
                e.Graphics.FillRectangle(bPlayer, rectPlayer);
                pen = new Pen(Color.Black, 2);
                e.Graphics.DrawRectangle(pen, rectPlayer);

                Font font = new System.Drawing.Font("Arial", 10.0f);
                e.Graphics.DrawString(p.Name, font, bBlack, new PointF(initX + 15, initY + 15));
                

                Console.WriteLine("{0} : X: {1} Y: {2}", p.Name, initX, initY);
                //initX = initX - 200;
                initY = initY - 100;
                if (playerIndex == 2) break;
            }
            //Font font = new System.Drawing.Font("Arial", 10.0f);
            //e.Graphics.DrawString("Bonjour", font, bBlack, new PointF(100, 100));*/
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            Player[] players = Table.TableInstance.Players;

            players[0].ChangeStatus(PlayerStatus.Out);
            players[1].ChangeStatus(PlayerStatus.BigBlind);
        }




        public void Updates(Subject aSubject)
        {
            this.panel1.Refresh();
        }
    }
}
